package com.szjlxh.domain.interactor;

import com.szjlxh.domain.executor.PostExecutionThread;
import com.szjlxh.domain.executor.ThreadExecutor;
import com.szjlxh.domain.repository.IBaseWeatherRespository;

import javax.inject.Inject;

import rx.Observable;
import rx.Subscriber;
import rx.schedulers.Schedulers;

/**
 * Created by liutao on 16/3/18.
 */
public class BaseWeatherInfoUserCase extends UseCase {
    public static final int BASE_WEATHER_CODE = 101;
    public static final int SEVEN_DAY_CODE = 102;
    public static final int FUTURE_24_HOUR_CODE = 103;
    public static final int LAST_24_HOUR_CODE = 104;
    public static final int GET_SATION_NAME_CODE = 105;

    private IBaseWeatherRespository baseWeatherRespository;
    @Inject
    protected BaseWeatherInfoUserCase(ThreadExecutor threadExecutor, PostExecutionThread postExecutionThread, IBaseWeatherRespository baseWeatherRespository) {
        super(threadExecutor, postExecutionThread);
        this.baseWeatherRespository = baseWeatherRespository;
    }

    @Override
    protected Observable buildUseCaseObservable() {
        return this.baseWeatherRespository.sunInfo();
    }

    public void execute(Subscriber useCaseSubscriber,int code) {
        switch (code) {
            case BaseWeatherInfoUserCase.BASE_WEATHER_CODE:
                execute(baseWeatherRespository.weatherBaseData(),useCaseSubscriber);
                break;
            case BaseWeatherInfoUserCase.SEVEN_DAY_CODE:
                execute(baseWeatherRespository.weatherSevenDay(),useCaseSubscriber);
                break;
            case BaseWeatherInfoUserCase.FUTURE_24_HOUR_CODE:
                execute(baseWeatherRespository.weatherFutureHourData(),useCaseSubscriber);
                break;
            case BaseWeatherInfoUserCase.LAST_24_HOUR_CODE:
                execute(baseWeatherRespository.weatherLastHourData(),useCaseSubscriber);
                break;
            case BaseWeatherInfoUserCase.GET_SATION_NAME_CODE:
                execute(baseWeatherRespository.weatherLastHourData(),useCaseSubscriber);
                break;
        }
    }
    //获取站点信息
    public void execute(Subscriber useCaseSubscriber,String lng,String lat) {
        execute(baseWeatherRespository.getStationName(lng,lat),useCaseSubscriber);
    }
}
